package initialize

import (
	"0227zk/common/config"
	"context"
	"fmt"
	"github.com/go-redis/redis/v8"
)

var Client *redis.Client

func Redis() {
	nas := config.Nas.Redis
	Client = redis.NewClient(&redis.Options{
		Addr:     nas.Addr,
		Password: "", // no password set
		DB:       0,  // use default DB
	})
	_, err = Client.Ping(context.Background()).Result()
	if err != nil {
		fmt.Println("redis连接失败")
	} else {
		fmt.Println("redis初始化成功")
	}
}
